﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
					xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" 
					xmlns:input="clr-namespace:SmartLib.UiComponents.InputControls">

	<LinearGradientBrush x:Key="TextBoxBorder" EndPoint="0,20" MappingMode="Absolute" StartPoint="0,0">
		<GradientStop Color="#ABADB3" Offset="0.05"/>
		<GradientStop Color="#E2E3EA" Offset="0.07"/>
		<GradientStop Color="#E3E9EF" Offset="1"/>
	</LinearGradientBrush>

	<ControlTemplate x:Key="AutoCompleteTextBoxTemplate" TargetType="{x:Type input:AutoCompleteTextBox}">
		<aero:ListBoxChrome x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" 
						BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" 
						RenderMouseOver="{TemplateBinding IsMouseOver}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" 
						SnapsToDevicePixels="true">
			<Grid x:Name="MainLayout">
				<TextBlock SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
					TextAlignment="{TemplateBinding TextAlignment}" Margin="1.5,0.0"
					VerticalAlignment="Center" HorizontalAlignment="Stretch" Foreground="LightBlue" 
					Text="{TemplateBinding HintText}" />

				<Decorator x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

				<Popup PlacementTarget="{Binding ElementName=MainLayout}" Width="{TemplateBinding ActualWidth}" x:Name="HintsPopup"
						IsOpen="{TemplateBinding IsHintsPopupOpen}" UseLayoutRounding="True" MaxHeight="240" VerticalOffset="4"
						AllowsTransparency="True" PopupAnimation="Scroll" StaysOpen="False">
					<ListBox ItemsSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=HintsViewSource.View}" 
							x:Name="HintsListBox" IsSynchronizedWithCurrentItem="True" SelectionMode="Single"
							Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}"
							SelectedItem="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=SelectedItem}"
							SelectedValuePath="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=SelectedValuePath}"
							SelectedValue="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=SelectedValue}"
							DisplayMemberPath="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=DisplayMemberPath}"/>
				</Popup>
			</Grid>
		</aero:ListBoxChrome>

		<ControlTemplate.Triggers>
			<Trigger Property="IsEnabled" Value="false">
				<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
				<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
			</Trigger>						
		</ControlTemplate.Triggers>
	</ControlTemplate>

	<Style TargetType="{x:Type input:AutoCompleteTextBox}">
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
		<Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="Padding" Value="1"/>
		<Setter Property="AllowDrop" Value="true"/>
		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
		<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
		<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
		<Setter Property="Template" Value="{StaticResource AutoCompleteTextBoxTemplate}"/>
	</Style>

</ResourceDictionary>